#ifndef _AUDIO_CAP_SDK_H_
#define _AUDIO_CAP_SDK_H_

#ifdef __cplusplus
extern "C" {
#endif 

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the AUDIOCAPSDK_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// AUDIOCAPSDK_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#define AUDIOCAPSDK_API __declspec(dllexport)

#define AUDIOCAP_OK		0
#define AUDIOCAP_ERR	-1

#define AUDIOCAP_FRAME_LENGTH_MAX		100 * 1024

typedef void* BTLAUDIOCAP_HANDLE;

typedef enum { 
	MONO	= 1, 
	STEREO	= 2 
} AudioChannel;

typedef enum { 
	BIT8	= 8, 
	BIT16	= 16 
} AudioBitPerSample;

typedef enum { 
	SAMPLERATE_8000HZ	= 8000,
	SAMPLERATE_11025HZ	= 11025, 
	SAMPLERATE_22050HZ	= 22050, 
	SAMPLERATE_44100HZ	= 44100,
	SAMPLERATE_48000HZ	= 48000
} AudioSamplePerSec;

// Export Interface

#ifndef _AUDIOCAP_SDK_DLL

typedef BTLAUDIOCAP_HANDLE (*BtlAudCapSdk_InitAudioCaptureDevice) (int, int, int, int);
typedef void (*BtlAudCapSdk_DisInitAudioCaptureDevice) (BTLAUDIOCAP_HANDLE);
typedef int (*BtlAudCapSdk_CaptureOneFrame) (BTLAUDIOCAP_HANDLE, char*, DWORD*);

#define	TEXT_BTLAUDCAPINITDEVICE	"BtlAudioCapSdk_InitAudioCaptureDevice"
#define	TEXT_BTLAUDCAPDISINIT		"BtlAudioCapSdk_DisInitAudioCaptureDevice"
#define	TEXT_BTLAUDCAPONEFRAME		"BtlAudioCapSdk_CaptureOneFrame"

#else

//-----------------------------------------------------------------------------
// Name: BtlAudioCapSdk_InitAudioCaptureDevice()
// Desc: Init Audio Capture Device
// Param:	I:deviceIndex->audio capture device index
//			I:channels->audio channel, 1-MONO,2-Stereo
//			I:bitsPerSample->audio bitsPerSample, 8bit or 16bit
//			I:samplesPerSec->audio SamplePerSec
// Return: AudioCap Handle-succeed, NULL-failed
//-----------------------------------------------------------------------------
AUDIOCAPSDK_API BTLAUDIOCAP_HANDLE BtlAudioCapSdk_InitAudioCaptureDevice(int deviceIndex, 
							int channels,
							int bitsPerSample,
							int samplesPerSec);

//-----------------------------------------------------------------------------
// Name: BtlAudioCapSdk_DisInitAudioCaptureDevice()
// Desc: Disinit Audio Capture Device
// Param:	I:handle->audio capture device handle
// Return: None
//-----------------------------------------------------------------------------
AUDIOCAPSDK_API void BtlAudioCapSdk_DisInitAudioCaptureDevice(BTLAUDIOCAP_HANDLE handle);

//-----------------------------------------------------------------------------
// Name: BtlAudioCapSdk_CaptureOneFrame()
// Desc: Capture One Audio Frame
// Param:	I:handle->audio capture device handle
//			O:pBuffer->capture buffer, user need malloc this buffer, 
//					maxsize = AUDIOCAP_FRAME_LENGTH_MAX.
//			O:length->frame length
// Return: AUDIOCAP_OK-succeed, AUDIOCAP_ERR-failed
//-----------------------------------------------------------------------------
AUDIOCAPSDK_API int BtlAudioCapSdk_CaptureOneFrame(BTLAUDIOCAP_HANDLE handle, 
														char *pBuffer, 
														DWORD *length);
#endif

#ifdef __cplusplus
}
#endif 

#endif // _AUDIO_CAP_SDK_H_